package com.ss.android.article.base.feature.detail2.b;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;

import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.account.Spipe;
import com.ss.android.action.a.a.Comment;
import com.ss.android.action.b.FeedViewHolder;
import com.ss.android.action.b.ImpressionHelper;
import com.ss.android.action.b.BaseDetailAdapter;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.a.ArticleConstants;
import com.ss.android.article.base.feature.detail.model.CommentWrapper;
import com.ss.android.article.base.feature.detail.presenter.AppAdViewHolder;
import com.ss.android.article.base.feature.detail.presenter.DetailHelper;
import com.ss.android.article.base.feature.detail.presenter.i;
import com.ss.android.article.base.feature.feed.FeedOnMovedToScrapHeapListener;
import com.ss.android.article.base.feature.feed.vh.CardViewPools;
import com.ss.android.article.base.feature.update.a.UserInfo;
import com.ss.android.article.base.feature.update.activity.UpdateDetailActivity;
import com.ss.android.article.base.feature.user.social.ReportActivity;
import com.ss.android.article.base.ui.DiggAnimationView;
import com.ss.android.article.base.utils.JSONObjectWrapper;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.LifeCycleMonitor;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.callback.SSCallback;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.util.UrlBuilder;
import com.ss.android.image.AvatarLoader;
import com.ss.android.image.BaseImageManager;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.model.AbsArticle;
import com.ss.android.model.ForumLink;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.newmedia.activity.browser.BrowserActivity;
import com.ss.android.newmedia.util.AppUtil;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public final class NewDetailAdapter extends BaseDetailAdapter implements LifeCycleMonitor {
    public interface a$a {
        boolean L();

        boolean a(CommentWrapper arg1);

        void addComment(CommentWrapper arg1);
    }

    private SSCallback commentExtraInfoChangedCallback;
    public long mAdId;
    public String e;
    public AbsArticle mArticle;
    public List<CommentWrapper> commentWrapperList;
    public boolean h;
    public boolean i;
    public com.ss.android.article.base.feature.detail.presenter.a j;
    public boolean k;
    public boolean l;
    private Context mContext;
    private Fragment mFragment;
    private AvatarLoader mAvatarLoader;
    private ImageLoader mImageLoader;
    private boolean q;
    private TaskInfo mTaskInfo;
    private BaseImageManager mImageMgr;
    private HashMap t;
    private Spipe u;
    private a$a v;
    private DiggAnimationView mDiggAnimationView;
    private CardViewPools mCardViewPools;
    private SSCallback y;
    private SSCallback z;

    public NewDetailAdapter(Context context, Fragment fragment, DiggAnimationView diggAnimationView) {
        this.commentWrapperList = new ArrayList();
        this.h = false;
        this.t = new HashMap();
        this.u = Spipe.inst();
        this.y = new SSCallback() {
            public final Object onCallback(Object[] args) {
                return NewDetailAdapter.this.b(args);
            }
        };
        this.z = new SSCallback() {
            public final Object onCallback(Object[] args) {
                return a(args);
            }
        };
        this.commentExtraInfoChangedCallback = new SSCallback() {

            public final Object onCallback(Object[] args) {
                Object v10 = null;
                if(args != null && args.length >= 5 && (BaseAppData.callbackTypeCommentExtraInfoChanged.equals(args[0]))) {
                    long commentId = ((Long) args[1]).longValue();
                    int v2 = ((Integer) args[2]).intValue();
                    int diggCount = ((Integer) args[3]).intValue();
                    boolean userDigg = ((Boolean) args[4]).booleanValue();
                    Iterator<CommentWrapper> iterator = NewDetailAdapter.this.commentWrapperList.iterator();
                    while(iterator.hasNext()) {
                        CommentWrapper commentWrapper = iterator.next();
                        if(commentWrapper == null) {
                            continue;
                        }

                        if(commentWrapper.mComment == null) {
                            continue;
                        }

                        if(commentWrapper.mComment.commentId != commentId) {
                            continue;
                        }

                        if(diggCount >= 0) {
                            commentWrapper.mComment.diggCount = diggCount;
                            commentWrapper.mComment.userDigg = userDigg;
                        }

                        if(v2 < 0) {
                            continue;
                        }

                        ((CommentWrapper)commentWrapper).mComment.replyCount = v2;
                    }

                    ListView listView = NewDetailAdapter.this.mListViewRef.get();
                    if(listView == null) {
                        return v10;
                    }

                    diggCount = ((ListView)listView).getChildCount();
                    for(v2 = 0; v2 < diggCount; ++v2) {
                        Object v1 = ((ListView)listView).getChildAt(v2).getTag();
                        if(((v1 instanceof CommentItemViewHolder)) && ((CommentItemViewHolder)v1).mCommentWrapper.mComment.commentId == commentId) {
                            ((CommentItemViewHolder)v1).diggLayout.setText(android.support.design.a.c(((CommentItemViewHolder)v1).mCommentWrapper.mComment.diggCount));
                            ((CommentItemViewHolder)v1).diggLayout.setSelected(((CommentItemViewHolder)v1).mCommentWrapper.mComment.userDigg);
                            ((CommentItemViewHolder)v1).a(((CommentItemViewHolder)v1).mCommentWrapper.mComment.replyCount);
                        }
                    }
                }

                return v10;
            }
        };
        this.mContext = context;
        this.mFragment = fragment;
        this.mDiggAnimationView = diggAnimationView;
        if ((this.mContext instanceof a$a)) {
            this.v = (a$a) context;
        }

        AppData.getInstance();
        this.mTaskInfo = new TaskInfo();
        this.mImageMgr = new BaseImageManager(context);
        CallbackCenter.addCallback(BaseAppData.callbackTypeCommentExtraInfoChanged, this.commentExtraInfoChangedCallback);
        int commentItemUserAvatarSize = context.getResources().getDimensionPixelSize(R.dimen.comment_item_user_avatar_size);
        this.q = true;
        this.mAvatarLoader = new AvatarLoader(
                com.ss.android.article.browser.R.drawable.ss_avatar_rounded,
                this.mTaskInfo,
                this.mImageMgr,
                commentItemUserAvatarSize << 1,
                commentItemUserAvatarSize / 2,
                true);
        DisplayMetrics displayMetrics = this.mContext.getResources().getDisplayMetrics();
        this.mImageLoader = new ImageLoader(this.mContext,
                this.mTaskInfo,
                16,
                20,
                2,
                this.mImageMgr,
                displayMetrics.widthPixels,
                displayMetrics.heightPixels);
        this.mCardViewPools = new CardViewPools();
    }

    public NewDetailAdapter(Context context, DiggAnimationView diggAnimationView) {
        this(context, null, diggAnimationView);
    }

    public final void addAllComment(List<CommentWrapper> commentList) {
        this.commentWrapperList.clear();
        if (commentList != null) {
            this.commentWrapperList.addAll(commentList);
        }
    }

    public final void a(int arg12) {
        View v0_3;
        Object v5_1;
        Object v1 = null;
        Object v0 = this.mListViewRef.get();
        if (v0 != null) {
            int v2 = ((ListView) v0).getHeaderViewsCount();
            int v5 = ((ListView) v0).getFirstVisiblePosition();
            int v7 = ((ListView) v0).getLastVisiblePosition() - v2;
            int v8 = v2 - v5;
            int v6;
            for (v6 = 0; v6 <= v7; ++v6) {
                int v0_1 = v6 >= this.getCount() || this.getComment(v6).cellType != 1 ? 0 : 1;
                if (v0_1 != 0) {
                    v2 = v6 + v8;
                    AbsListView v0_2 = this.c();
                    if (v0_2 == null) {
                        v5_1 = v1;
                    } else {
                        v0_3 = ((ListView) v0_2).getChildAt(v2);
                        if (v0_3 == null) {
                            v5_1 = v1;
                        } else {
                            v0 = v0_3.getTag();
                            if (!(v0 instanceof CommentItemViewHolder)) {
                                v0 = v1;
                            }

                            v5_1 = v0;
                        }
                    }

                    if (v5_1 == null) {
                        continue;
                    }

                    v0_3 = ((CommentItemViewHolder) v5_1).itemView;
                    if (v0_3 == null) {
                        continue;
                    }

                    if (v5_1 != null) {
                        if (this.t == null) {
                            this.t = new HashMap();
                        }

                        String v2_1 = a(((CommentItemViewHolder) v5_1));
                        if (android.support.design.a.isTextEmpty(v2_1)) {
                        } else if (this.t.containsKey(v2_1)) {
                        } else {
                            this.t.put(v2_1, Boolean.valueOf(false));
                        }
                    }

                    String v9 = a(((CommentItemViewHolder) v5_1));
                    if (android.support.design.a.isTextEmpty(v9)) {
                        continue;
                    }

                    HashMap v10 = this.t;
                    boolean v2_2 = arg12 >= v0_3.getTop() ? true : false;
                    if (v2_2 == ((Boolean) v10.get(v9)).booleanValue()) {
                        continue;
                    }

                    v10.remove(v9);
                    v10.put(v9, Boolean.valueOf(v2_2));
                    if (v2_2) {
                        this.a(((FeedViewHolder) v5_1));
                    } else {
                        this.b(((FeedViewHolder) v5_1));
                    }
                }
            }
        }
    }

    private static String a(CommentItemViewHolder arg6) {
        String v0 = null;
        if (arg6 != null && arg6.mCommentWrapper != null && arg6.mCommentWrapper.mComment != null) {
            Comment v1 = arg6.mCommentWrapper.mComment;
            if (v1.commentId > 0) {
                v0 = String.valueOf(v1.commentId);
            }
        }

        return v0;
    }

    static WeakReference a(NewDetailAdapter arg1) {
        return arg1.mListViewRef;
    }

    private void a(Comment arg10) {
        if (!this.l) {
            boolean v0 = (this.mContext instanceof DetailHelper.SimpleArticle)
                    ? ((DetailHelper.SimpleArticle) this.mContext).getArticle().mBanComment
                    : false;
            if (v0) {
                return;
            }

            if (arg10 == null) {
                return;
            }

            if (!this.i) {
                return;
            }

            com.ss.android.article.base.feature.update.a.d v0_1 = new com.ss.android.article.base.feature.update.a.d(-1);
            UserInfo v1 = new UserInfo(arg10.userId);
            v1.avatarUrl = arg10.avatarUrl;
            v1.screenName = arg10.userName;
            v1.verifiedReason = arg10.verifiedReason;
            v0_1.o = v1;
            v0_1.b = arg10.diggCount;
            v0_1.c = arg10.replyCount;
            v0_1.k = arg10.text;
            v0_1.s = arg10.createTime;
            if (this.mArticle == null) {
                return;
            }

            com.ss.android.article.base.feature.update.a.e v4 = new com.ss.android.article.base.feature.update.a.e(((com.ss.android.article.base.feature.update.a.a) v0_1));
            Context v0_2 = this.mContext;
            Fragment v1_1 = this.mFragment;
            long v2 = arg10.commentId;
            long v6 = this.mAdId;
            boolean v8 = !TextUtils.isEmpty(arg10.mediaId) ? true : false;
            UpdateDetailActivity.a(v0_2, v1_1, v2, v4, false, v6, v8);
        } else if (this.j != null) {
            this.j.b(arg10);
        }
    }

    private void a(Comment comment, boolean arg6) {
        if (comment != null) {
            String v0 = arg6 ? "click_avatar" : "click_name";
            MobClickCombiner.onEvent(this.mContext, "comment", v0);
            if (comment.userId > 0) {
                return;
            }

            if (android.support.design.a.isTextEmpty(comment.userProfileUrl)) {
                return;
            }

            v0 = comment.userProfileUrl.toLowerCase();
            if (!TTUtils.isValidUrl(v0)) {
                return;
            }

            try {
                Intent v1 = new Intent(this.mContext, BrowserActivity.class);
                v1.setData(Uri.parse(v0));
                this.mContext.startActivity(v1);
            } catch (Exception v0_1) {
            }
        }
    }

    final Object a(Object[] arg11) {
        Object v9 = null;
        if (arg11 != null && arg11.length >= 3) {
            try {
                int v1 = ((Integer) arg11[0]).intValue();
                Object v0_1 = arg11[1];
                switch (v1) {
                    case 1:
                    case 2: {
                        if (android.support.design.a.isTextEmpty(((com.ss.android.article.base.feature.detail.presenter.f) v0_1).A.mForumPostData.url)) {
                            return v9;
                        }
                        AppUtil.b(this.mContext, ((com.ss.android.article.base.feature.detail.presenter.f) v0_1).A.mForumPostData.url);
                        return v9;
                    }
                    case 3: {
                        ForumLink v1_1 = ((com.ss.android.article.base.feature.detail.presenter.f) v0_1).A.mForumPostData.forumLink;
                        if (v1_1 == null) {
                            return v9;
                        }

                        if (v1_1.a == null) {
                            return v9;
                        }

                        AppUtil.b(this.mContext, v1_1.a);
                        MobClickCombiner.onEvent(this.mContext, "forum_detail", "click_detail_comment_ad", 0, this.mArticle.groupId, new JSONObjectWrapper().put("forum_id", ((com.ss.android.article.base.feature.detail.presenter.f) v0_1).A.mForumPostData.id).jsonObject);
                        return v9;
                    }
                }
                return v9;
            } catch (Exception exception) {
                Logger.throwExceptionInDebug(((Throwable) exception));
            }
        }

        return v9;
    }

    public final boolean a() {
        boolean v0 = !this.a ? false : this.h;
        return v0;
    }

    public final boolean a(int arg2, FeedViewHolder arg3) {
        boolean v0 = !this.a ? false : this.h;
        return v0;
    }

    private CommentWrapper getComment(int index) {
        return this.commentWrapperList.get(index);
    }

    final Object b(Object[] arg13) {
        Context v0_4;
        int v0_3;
        int v1 = 3;
        long v4 = 0;
        Object v11 = null;
        boolean v8 = true;
        int v9 = 0;
        if (arg13 != null && arg13.length >= v1) {
            try {
                v1 = ((Integer) arg13[0]).intValue();
                Object v0_1 = arg13[2];
                CommentWrapper v2 = ((CommentItemViewHolder) v0_1).mCommentWrapper;
                switch (v1) {
                    case 3: {
                        Comment v10 = v2.mComment;
                        if (v10 == null) {
                            return v11;
                        }

                        if (this.u != null && (this.u.isLogin)) {
                            if (v10.spipeUser != null) {
                                if (!v10.spipeUser.isBlocking() && !v10.spipeUser.isBlocked()) {
                                    v0_3 = 0;
                                } else {
                                    v0_3 = 1;
                                }
                            } else {
                                label_83:
                                v0_3 = 0;
                            }

                            if (v0_3 == 0) {
//                                goto label_90;
                            } else {
                                v0_4 = this.mContext;
                                v1 = R.drawable.close_popup_textpage;
                                if (v10.spipeUser.isBlocking()) {
                                    v9 = R.string.user_toast_has_blocking;
                                } else if (v10.spipeUser.isBlocked()) {
                                    v9 = R.string.user_toast_has_blocked;
                                }
                                UIUtils.showImageToast(v0_4, v1, v9);
                                return v11;
                            }
                        }
                        if (this.i) {
                            AppData.getInstance();
                            boolean v5 = v10.replyCount <= 0 ? true : false;
                            v0_4 = this.mContext;
                            Fragment v1_2 = this.mFragment;
                            long v2_1 = v10.commentId;
                            com.ss.android.article.base.feature.update.a.e v4_1 = null;
                            long v6 = this.mAdId;
                            if (TextUtils.isEmpty(v10.mediaId)) {
                                v8 = false;
                            }

                            UpdateDetailActivity.a(v0_4, v1_2, v2_1, v4_1, v5, v6, v8);
                            return v11;
                        }

                        if (this.j == null) {
                            return v11;
                        }

                        if (this.u.userId == v10.userId) {
                            this.j.deleteComment(v10);
                            return v11;
                        }

                        this.j.b(v10);
                        return v11;
                    }
                    case 4: {
                        ForumLink forumLink = ((CommentItemViewHolder) v0_1).mCommentWrapper.mComment.forumLink;
                        if (forumLink == null) {
                            return v11;
                        }

                        if (android.support.design.a.isTextEmpty(forumLink.a)) {
                            return v11;
                        }

                        AppUtil.b(this.mContext, forumLink.a);
                        MobClickCombiner.onEvent(this.mContext, "forum_detail", "click_detail_comment", 0, this.mArticle.groupId);
                        return v11;
                    }
                    case 5:
                    case 6: {
                        label_24:
                        if (!android.support.design.a.isTextEmpty(v2.mComment.openUrl)) {
                            AppUtil.b(this.mContext, v2.mComment.openUrl);
                        } else {
                            this.a(v2.mComment);
                        }

                        MobClickCombiner.onEvent(this.mContext, "comment", "click_comment");
                        return v11;
                    }
                    case 1:
                    case 7: {
                        Comment v0_2 = v2.mComment;
                        if (v1 != 1) {
                            v8 = false;
                        }

                        this.a(v0_2, v8);
                        return v11;
                    }
                    case 8: {
                        this.a(v2.mComment);
                        MobClickCombiner.onEvent(this.mContext, "comment", "click_comment");
                        return v11;
                    }
                    case 9: {
                        label_141:
                        if (this.j == null) {
                            return v11;
                        }

                        this.j.deleteComment(v2.mComment);
                        return v11;
                    }
                    case 10:
                    case 11: {
                        label_40:
                        MobClickCombiner.onEvent(this.mContext, "update_detail", "enter_detail_comment");
                        this.a(v2.mComment);
                        MobClickCombiner.onEvent(this.mContext, "comment", "click_comment");
                        return v11;
                    }
                    case 12: {
                        this.a((Comment) arg13[3], false);
                        return v11;
                    }
                    case 14: {
                        Comment v0_2 = v2.mComment;
                        if (v0_2 == null) {
                            return v11;
                        }

                        if (v0_2.userId <= v4) {
                            return v11;
                        }

                        if (v0_2.groupId <= v4) {
                            return v11;
                        }

                        if (v0_2.commentId <= v4) {
                            return v11;
                        }

                        UrlBuilder v1_1 = new UrlBuilder(ArticleConstants.feedbackWapListReportUserUrl);
                        v1_1.addParam("user_id", v0_2.userId);
                        v1_1.addParam("group_id", v0_2.groupId);
                        v1_1.addParam("comment_id", v0_2.commentId);
                        v1_1.addParam("source", 1);
                        ReportActivity.a(this.mContext, v1_1.build());
                        return v11;
                    }
                }

                return v11;
            } catch (Exception v0) {
                Logger.throwExceptionInDebug(((Throwable) v0));
            }
        }

        return v11;
    }

    public final com.ss.android.action.b.b d() {
        if (this.b == null) {
            String v0 = null;
            if (this.mArticle != null) {
                JSONObjectWrapper v0_1 = new JSONObjectWrapper();
                v0_1.put("item_id", this.mArticle.itemId);
                v0_1.put("aggr_type", this.mArticle.aggrType);
                v0 = v0_1.jsonObject.toString();
            }

            this.b = ImpressionHelper.getInstance().a(2, this.e, v0);
        }

        return this.b;
    }

    public final void onDestroy() {
        this.mTaskInfo.a = true;
        if (this.q) {
            this.mAvatarLoader.onDestroy();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onDestroy();
        }

        if (this.b != null && !android.support.design.a.isTextEmpty(this.e)) {
            ImpressionHelper.getInstance().a(this.b, this.e);
        }

        CallbackCenter.removeCallback(BaseAppData.callbackTypeCommentExtraInfoChanged, this.commentExtraInfoChangedCallback);
    }

    public final void onResume() {
        if (this.q) {
            this.mAvatarLoader.onPause();
        }

        this.a = true;
        if (!this.commentWrapperList.isEmpty()) {
            this.g_();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onPause();
        }
    }

    public final void onPause() {
        this.f();
        this.a = false;
    }

    public final boolean hasComments() {
        return this.commentWrapperList.isEmpty();
    }

    public final int getCount() {
        return this.commentWrapperList.size();
    }

    public final Object getItem(int position) {
        return this.getComment(position);
    }

    public final long getItemId(int arg3) {
        return ((long) arg3);
    }

    public final int getItemViewType(int arg4) {
        CommentWrapper v1 = this.getComment(arg4);
        int v0 = -1;
        switch (v1.cellType) {
            case 1: {
                v0 = 0;
                break;
            }
            case 2: {
                v0 = 1;
                break;
            }
            case 3: {
                switch (v1.d) {
                    case 2: {
                        return 2;
                    }
                    case 1:
                    case 3: {
                        return 3;
                    }
                    default: {
                        return v0;
                    }
                }
            }
        }

        return v0;
    }

    public final View getView(int position, View convertView, ViewGroup parent) {
        CommentItemViewHolder commentItemViewHolder;
        com.ss.android.article.base.feature.detail.presenter.f v0_2;
        boolean v1_1;
        int v6 = R.id.divider;
        int v9 = 5;
        Drawable v8 = null;
        boolean v2 = false;
        CommentWrapper v4 = this.getComment(position);
        switch (v4.cellType) {
            case 1: {
                if (convertView == null) {
                    commentItemViewHolder = new CommentItemViewHolder(this.mContext, this.mDiggAnimationView, this.mCardViewPools, this.l);
                    commentItemViewHolder.itemView = LayoutInflater.from(commentItemViewHolder.mContext).inflate(com.ss.android.article.browser.R.layout.comment_item, parent, false);
                    commentItemViewHolder.itemView.setTag(commentItemViewHolder);
                    commentItemViewHolder.ssAvatarIv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.ss_avatar);
                    commentItemViewHolder.ssUserTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.ss_user);
                    commentItemViewHolder.verifiedTextTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.verified_text);
                    commentItemViewHolder.verifiedImgIv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.verified_img);
                    commentItemViewHolder.nameWrapperLL = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.name_wrapper);
                    commentItemViewHolder.descriptionTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.description);
                    commentItemViewHolder.diggLayout = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.digg_layout);
                    commentItemViewHolder.diggLayout.setTextColor$255f295(com.ss.android.article.browser.R.color.ssxinzi9);
                    commentItemViewHolder.diggLayout.a(com.ss.android.article.browser.R.drawable.nt, R.drawable.ns, commentItemViewHolder.isNightMode);
                    commentItemViewHolder.diggLayout.setDrawablePadding(0f);
                    commentItemViewHolder.commentCountTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.comment_count);
                    if (commentItemViewHolder.L) {
                        commentItemViewHolder.commentCountTv.setCompoundDrawablesWithIntrinsicBounds(v8, v8, v8, v8);
                    }

                    commentItemViewHolder.contentTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.content);
                    commentItemViewHolder.contentTv.setOnEllipsisStatusChangeListener((com.ss.android.article.base.ui.EllipsisTextView.a) commentItemViewHolder);
                    commentItemViewHolder.forumTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.forum);
                    commentItemViewHolder.btnViewAllTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.btn_view_all);
                    commentItemViewHolder.deleteTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.delete);
                    commentItemViewHolder.subCommentsLL = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.sub_comments);
                    commentItemViewHolder.toutiaoHaoTagTv = commentItemViewHolder.itemView.findViewById(com.ss.android.article.browser.R.id.toutiaohao_tag);
                    commentItemViewHolder.ssAvatarIv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.diggLayout.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.commentCountTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.contentTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.forumTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.itemView.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.ssUserTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.btnViewAllTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.deleteTv.setOnClickListener(commentItemViewHolder);
                    commentItemViewHolder.itemView.setOnLongClickListener(commentItemViewHolder);
                    commentItemViewHolder.contentTv.setOnLongClickListener(commentItemViewHolder);
                    commentItemViewHolder.diggLayout.setDiggAnimationView(commentItemViewHolder.mDiggAnimationView);
                    com.ss.android.article.base.feature.detail2.config.a.a(v9, commentItemViewHolder.ssUserTv);
                    com.ss.android.article.base.feature.detail2.config.a.b(v9, commentItemViewHolder.ssUserTv);
                    commentItemViewHolder.mImageLoader = this.mImageLoader;
                    commentItemViewHolder.E = this.y;
                } else {
                    commentItemViewHolder = (CommentItemViewHolder) convertView.getTag();
                }

                if (this.v != null) {
                    if (!this.v.L()) {
                        v1_1 = false;
                    } else {
                        boolean v5_1 = this.v.a(v4);
                        v1_1 = !v5_1 ? true : false;
                        if (v5_1) {
                        } else {
                            this.v.addComment(v4);
                        }
                    }
                    commentItemViewHolder.bindData(this.mArticle, v4, v1_1, this.k);
                } else {
                    commentItemViewHolder.bindData(this.mArticle, v4, true, this.k);
                }

                commentItemViewHolder.a(20, String.valueOf(v4.mComment.commentId));
                if (this.a(position, ((FeedViewHolder) commentItemViewHolder))) {
                    this.a(((FeedViewHolder) commentItemViewHolder));
                }
                return commentItemViewHolder.itemView;
            }
            case 2: {
                if (convertView == null) {
                    com.ss.android.article.base.feature.detail.presenter.f v1_2 = new com.ss.android.article.base.feature.detail.presenter.f(this.mContext, this.mImageLoader);
                    v1_2.p = LayoutInflater.from(v1_2.o).inflate(com.ss.android.article.browser.R.layout.comment_forum, parent, false);
                    v1_2.p.setTag(v1_2);
                    v1_2.q = v1_2.p.findViewById(com.ss.android.article.browser.R.id.icon);
                    v1_2.r = v1_2.p.findViewById(com.ss.android.article.browser.R.id.releated_title);
                    v1_2.t = v1_2.p.findViewById(com.ss.android.article.browser.R.id.forum_title);
                    v1_2.s = v1_2.p.findViewById(com.ss.android.article.browser.R.id.description);
                    v1_2.u = v1_2.p.findViewById(com.ss.android.article.browser.R.id.author_name);
                    v1_2.x = v1_2.p.findViewById(com.ss.android.article.browser.R.id.image_wrapper);
                    v1_2.v = v1_2.p.findViewById(com.ss.android.article.browser.R.id.images);
                    v1_2.w = v1_2.p.findViewById(com.ss.android.article.browser.R.id.label);
                    v1_2.y = v1_2.p.findViewById(v6);
                    v1_2.p.setOnClickListener(((View.OnClickListener) v1_2));
                    v1_2.s.setOnClickListener(((View.OnClickListener) v1_2));
                    v1_2.t.setOnClickListener(((View.OnClickListener) v1_2));
                    v1_2.d();
                    v1_2.z = this.z;
                    v0_2 = v1_2;
                } else {
                    v0_2 = (com.ss.android.article.base.feature.detail.presenter.f) convertView.getTag();
                }

                if (this.v != null) {
                    if (this.v.L()) {
                        v1_1 = this.v.a(v4);
                        if (!v1_1) {
                            v2 = true;
                        }

                        if (v1_1) {
                        } else {
                            this.v.addComment(v4);
                        }
                    }
                    v0_2.a(this.mArticle, v4, v2);
                } else {
                    v0_2.a(this.mArticle, v4, true);
                }

                return v0_2.p;
            }
            case 3: {
                switch (v4.d) {
                    case 2: {
                        AppAdViewHolder v0_1 = new AppAdViewHolder(this.mContext, this.mImageLoader);
                        v0_1.a(parent);
                        if (this.v != null) {
                            if (this.v.L()) {
                                v1_1 = this.v.a(v4);
                                if (!v1_1) {
                                    v2 = true;
                                }

                                if (v1_1) {
                                } else {
                                    this.v.addComment(v4);
                                }
                            }

                            v0_1.a(v4, v2);
                        } else {
                            v0_1.a(v4, true);
                        }

                        return v0_1.a;


                    }
                    case 1:
                    case 3: {
                        i v1 = new i(this.mContext, this.mImageLoader);
                        v1.b = LayoutInflater.from(v1.a).inflate(com.ss.android.article.browser.R.layout.comment_ad_banner, parent, false);
                        v1.b.setTag(v1);
                        View v5 = v1.b;
                        v1.d = v5.findViewById(com.ss.android.article.browser.R.id.ad_layout);
                        v1.e = v5.findViewById(com.ss.android.article.browser.R.id.ad_image);
                        v1.g = v5.findViewById(com.ss.android.article.browser.R.id.ad_image_lable);
                        v1.f = v5.findViewById(com.ss.android.article.browser.R.id.ad_desc);
                        v1.c = v1.b.findViewById(v6);
                        if (this.v != null) {
                            if (this.v.L()) {
                                boolean v0 = this.v.a(v4);
                                if (!v0) {
                                    v2 = true;
                                }

                                if (v0) {
                                } else {
                                    this.v.addComment(v4);
                                }
                            }

                            v1.a(v4, v2);
                        } else {
                            v1.a(v4, true);
                        }

                        return v1.b;
                    }
                    default: {
                        if (convertView != null) {
                            return convertView;
                        }

                        return new View(this.mContext);
                    }
                }
            }
            default: {
            }
        }

        return convertView;
    }

    public final int getViewTypeCount() {
        return 4;
    }

    public final void onStop() {
        if (this.q) {
            this.mAvatarLoader.onStop();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onStop();
        }
    }

    public final void onMovedToScrapHeap(View arg4) {
        super.onMovedToScrapHeap(arg4);
        Object v1 = arg4 != null ? arg4.getTag() : null;
        if ((v1 instanceof CommentItemViewHolder)) {
            String v0 = a((CommentItemViewHolder) v1);
            if (!android.support.design.a.isTextEmpty(v0)) {
                this.t.remove(v0);
                if ((v1 instanceof FeedOnMovedToScrapHeapListener)) {
                    ((FeedOnMovedToScrapHeapListener) v1).onMovedToScrapHeap();
                }
            }
        } else {
            if ((v1 instanceof FeedOnMovedToScrapHeapListener)) {
                ((FeedOnMovedToScrapHeapListener) v1).onMovedToScrapHeap();
            }
        }
    }
}

